




/**
* @file rev.c
* @brief 测试
* @author zshare
* @version v1.0
* @date 2022-03-11
* @history  
*	
*	
*/


#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include "msg.h"

	
int main(){
	u8 buff[1024] = {0};
	u8 *pos = buff;
	head_st *head = nil;
	body_st *body = nil;
	u32 i = 0;
	int fd = open(test_rev_chan, O_RDWR);//以可读可写方式打开

	if(fd < 0){
		log_print("open failed.\n");
		return -1;
	}

	read(fd, buff, 1);
	for(i = 0;i < 32;i++){
		printf("%02x ",buff[i]);
	}
	printf("\n");
	
	close(fd);

	head = (head_st *)pos;
	printf("msg:\n");
	if(head->src == BOB){ printf("\tfrom: BOB\n");}
	else{ printf("\tfrom: unknow\n");}
	printf("\ttext:");
	pos+=sizeof(head_st);
	body = (body_st *)pos;
	for(i = 0;i < body->len;i++){
		printf("%02x ", body->data[i]);
	}
	printf("\n");
	return 0;
}



















